<%--
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" %>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Goodwill - Взаимодействие с 1С</title>
    <link rel="stylesheet" href="resources/css/main.css"/>
    <link rel="stylesheet" href="resources/css/stylesheet.css"/>
    <link rel="stylesheet" href="resources/css/clients.css"/>
    <script type="text/javascript">

        //  Удалить задание на обмен
        function removeDataExchange(id)
        {
            if (confirm("Вы уверены, что хотите удалить задание на обмен?"))
                _removeDataExchange(id);
        }
    </script>
    <style type="text/css">
    </style>
</head>
<body>
<f:view>
    <a4j:form id="jsForm" prependId="false">
        <a4j:jsFunction name="_removeDataExchange" action="#{Logs1CBean.removeDataExchange}" reRender="divMain">
            <a4j:actionparam name="id" assignTo="#{Logs1CBean.removeId}"/>
        </a4j:jsFunction>
    </a4j:form>

    <jsp:include page="status.jsp"/>

    <h:panelGroup id="divMain">
        <h:panelGroup styleClass="" layout="block"
                      style="margin:5px;padding:2px;border:1px solid black;background:whitesmoke">
            <h:panelGrid columns="2" cellpadding="0" cellspacing="0" columnClasses="dleft,dright">

                <h:panelGroup>
                    <h:outputText value="Текущее состояние обмена" styleClass="b"/>
                </h:panelGroup>
                <h:panelGroup>
                    <h:outputText value="#{Logs1CBean.currentStateAsString}" escape="false"/>
                </h:panelGroup>

                <h:panelGroup>
                    <h:outputText value="Последний обмен данными с 1С" styleClass="b"/>
                </h:panelGroup>
                <h:panelGroup>
                    <h:outputText value="#{Logs1CBean.lastExchangeDateAsString}" escape="false"/>
                </h:panelGroup>

                <h:panelGroup>
                    <h:outputText value="Последняя загрузка остатков" styleClass="b"/>
                </h:panelGroup>
                <h:panelGroup>
                    <h:outputText value="#{Logs1CBean.lastRestsImportDateAsString}" escape="false"/>
                </h:panelGroup>
            </h:panelGrid>
        </h:panelGroup>

        <h:panelGroup styleClass="" layout="block"
                      style="margin:5px;padding:2px;border:3px solid red;background:whitesmoke" rendered="#{Logs1CBean.c1ErrorExists}">
            <h:panelGroup styleClass="" layout="block" rendered="#{Logs1CBean.c1ErrorExists}">
                <h:outputText value="Ошибка" style="font-size:140%;font-weight:bold;"/><br>
                <rich:dataTable value="#{Logs1CBean.c1Error}" var="item">
                    <f:facet name="header">
                        <h:outputText value="Описание ошибки" styleClass="b"/>
                    </f:facet>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="ПАРАМЕТР"/>
                        </f:facet>
                        <h:outputText value="#{item.s1}"/>
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="ЗНАЧЕНИЕ"/>
                        </f:facet>
                        <h:outputText value="#{item.s2}"/>
                    </rich:column>
                </rich:dataTable>
                <h:form>
                    <a4j:commandButton action="#{Logs1CBean.restart}" value="Перезапуск" reRender="divMain"/>
                </h:form>
            </h:panelGroup>
        </h:panelGroup>

        <h:panelGroup styleClass="" layout="block"
                      style="margin:5px;padding:2px;border:1px solid black;background:whitesmoke">
            <rich:dataTable id="exchangeTable" value="#{Logs1CBean.logs}" cellpadding="0" cellspacing="0" var="log">
                <f:facet name="header">
                    <h:outputText value="Протокол"/>
                </f:facet>
                <rich:column>
                    <f:facet name="header">
                        <h:outputText value="#"/>
                    </f:facet>
                    <h:outputText value="#{log.num}" escape="false"/>
                </rich:column>
                <rich:column>
                    <h:outputLink value="#" onclick="removeDataExchange(#{log.num});">удалить</h:outputLink>
                </rich:column>
                <rich:column>
                    <f:facet name="header">
                        <h:outputText value="Тип"/>
                    </f:facet>
                    <h:outputText value="#{log.type}" escape="false"/>
                </rich:column>
                <rich:column>
                    <f:facet name="header">
                        <h:outputText value="Наименование"/>
                    </f:facet>
                    <h:outputText value="#{log.item}" escape="false"/>
                </rich:column>
                <rich:column>
                    <f:facet name="header">
                        <h:outputText value="Статус"/>
                    </f:facet>
                    <h:outputText value="#{log.state}" escape="false"/>
                </rich:column>
                <rich:column>
                    <f:facet name="header">
                        <h:outputText value="Дата"/>
                    </f:facet>
                    <h:outputText value="#{log.timestamp}" converter="TimestampConverter"/>
                </rich:column>
            </rich:dataTable>
        </h:panelGroup>
    </h:panelGroup>
</f:view>
</body>
</html>